package com.feishi.core.socket.common.decoder;

import com.feishi.core.analytic.assembler.BaseAssembler;
import com.feishi.core.analytic.assembler.DefaultAssembler;
import com.feishi.core.socket.common.SocketDecoder;
import com.feishi.core.util.common.bean.ByteBufferProxy;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: caixq
 * Date: 2018-12-25
 * Time: 上午10:26
 */
public class NoneDecoder<T extends BaseAssembler> implements SocketDecoder<T> {

    @Override
    public byte[] decode(ByteBufferProxy bfp) {
        if (bfp.get().length != 0) {
            byte[] out = bfp.get();
            bfp.clear();
            return out;
        }
        return null;
    }

    private Class<T> assemblerClass= (Class<T>) DefaultAssembler.class;
    @Override
    public Class<T> getAssemblerClass() {
        return assemblerClass;
    }
}
